const COUNT = cc.v2(8,4)
const {ccclass, property} = cc._decorator;

@ccclass
export default class Pack extends cc.Component {
    @property(cc.ScrollView)
    scrollView: cc.ScrollView = null;
    @property(cc.Node)
    item: cc.Node = null;


    onLoad () {
    }

    start () {

    }

    public onClick(_, data) {
        cc.log(data);
    }

    private _setItem(goods: any[]) {
        this.scrollView.content.removeAllChildren();
        goods.forEach((data) => {
            const it = cc.instantiate(this.item);
            it.parent = this.scrollView.content;

            let flag = it.getChildByName('imgFlag');
            var clickEventHandler = new cc.Component.EventHandler();
            clickEventHandler.target = this.node; // 这个 node 节点是你的事件处理代码组件所属的节点
            clickEventHandler.component = "Mall";// 这个是代码文件名
            clickEventHandler.handler = "onClick";
            clickEventHandler.customEventData = JSON.stringify(data);
            it.getComponent('TouchNode').clickEvent = clickEventHandler;
        });

        this.scrollView.scrollToTopLeft();
    }
}
